package com.house365.core.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.widget.BaseAdapter;

public abstract class BaseListAdapter<T> extends BaseAdapter
{
  protected Context context;
  protected final List<T> list;

  public BaseListAdapter(Context context)
  {
	this.context = context;
    this.list = new ArrayList<T>();
  }

  public boolean addAll(List<? extends T> list)
  {
    return this.list.addAll(list);
  }

  public void clear()
  {
    this.list.clear();
  }

  public int getCount()
  {
    return list==null?0:list.size();
  }

  public T getItem(int i)
  {
    return this.list.get(i);
  }

  public long getItemId(int id)
  {
    return id;
  }

  public boolean hasStableIds()
  {
    return true;
  }

  public boolean isEmpty()
  {
    return list==null?true:list.isEmpty();
  }

  public T remove(int i)
  {
    return list.remove(i);
  }
  
  public void addItem(T t){
	  this.list.add(t);
  }
  
  public List<T> getList() {
	  return list;
  }
  
}
